<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增专栏详情')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-specialcolumninfo-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">主题：</label>
                <div class="col-sm-8">
                    <input name="title" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">介绍：</label>
                <div class="col-sm-8">
                    <textarea name="detail" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="columnDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" style="display: none;">
                <label class="col-sm-3 control-label">父节点ID：</label>
                <div class="col-sm-8">
                    <input name="parentId" class="form-control" type="text" th:value="${parentId}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">视频上传：</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="video_input" class="file" type="file" data-theme="fas">
                    </div>
                    <input id="video_name_input" name="videoName" class="form-control" type="hidden">
                    <input id="video_url_input" name="videoUrl" class="form-control" type="hidden">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_notice_status')}">
                        <input type="radio" th:id="${dict.dictCode}" name="state" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        $("#video_input").fileinput('destroy');
        $("#video_input").fileinput({
            'theme': 'explorer-fas',
            language: 'zh', //设置语言
            uploadUrl: ctx + "common/uploads",
            dropZoneTitle: '请选择将要上传的视频',
            allowedFileExtensions: ["mp4", "avi", "dat", "3gp", "mov", "rmvb"],
            minFileCount: 1,
            maxFileCount: 1,
            showRemove:false
        });
        $("#video_input").on("fileuploaded", function(event, data, previewId, index) {
            var fn = $("#video_name_input").val();
            var fu = $("#video_url_input").val();
            if(fn == null || fn.length == 0){
                fn = data.response.fileName;
            }else{
                fn += "?" + data.response.fileName;
            }
            if(fu == null || fu.length == 0){
                fu = data.response.url;
            }else{
                fu += "?" + data.response.url;
            }
            $("#video_name_input").val(fn);
            $("#video_url_input").val(fu);
        });

        $("#video_input").on("filesuccessremove", function (event, data, previewId, index) {
            var fn = $("#video_name_input").val();
            var fu = $("#video_url_input").val();
            var fns = fn.split("?");
            var fus = fu.split("?");
            fns.splice(previewId,1);
            fus.splice(previewId,1);
            $("#video_name_input").val(fns.join("?"));
            $("#video_url_input").val(fus.join("?"));
        });
        $('#video_input').on('filedeleted', function(event, data, previewId, index) {
            var fn = $("#video_name_input").val();
            var fu = $("#video_url_input").val();
            var fns = fn.split("?");
            var fus = fu.split("?");
            for(var i=0;i<fns.length;i++){
                if(fns[i] == data){
                    fns.splice(i,1);
                    fus.splice(i,1);
                }
            }
            $("#video_name_input").val(fns.join("?"));
            $("#video_url_input").val(fus.join("?"));
        });

        var prefix = ctx + "bnt/specialcolumn/specialcolumninfo"
        $("#form-specialcolumninfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-specialcolumninfo-add').serialize());
            }
        }

        $("input[name='columnDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>